<%-- 
    Document   : triagem
    Created on : Nov 17, 2012, 1:15:47 PM
    Author     : Gattini
--%>

<%@page import="br.com.maternity.classes.entity.Exame"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="br.com.maternity.classes.dao.ExameDAO"%>
<%@page import="br.com.maternity.componentes.dropdownlist.DropDownList"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="br.com.maternity.classes.dao.AtendimentoDAO"%>
<%@page import="br.com.maternity.classes.entity.Atendimento"%>
<%@page import="br.com.maternity.util.Parser"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:include page="../cabecalho.jsp"></jsp:include>
<%

    String id, paciente = "", data = "", responsavel = "", servletUrl = request.getContextPath() + "/enfObstetria";
    id = Parser.parseString(request.getParameter("atendimento"));
    if (id.isEmpty()) {
        response.getWriter().write("<script>window.location.href='" + request.getContextPath() + "/relatorios/frmObstetria.jsp';</script>");
    } else {
        Atendimento a = new AtendimentoDAO().getById(Integer.parseInt(id));
        if (a == null) {
            response.getWriter().write("<script>window.location.href='" + request.getContextPath() + "/relatorios/frmObstetria.jsp';</script>");
        } else {
            paciente = a.getPacienteNome();
            responsavel = a.getResponsavelNome();
            data = Parser.parseDateToString(a.getPaciente().getDataNascimento());
        }
    }
%>
<div id="titulo">Obstetra</div>
<div id="erro"></div>
<div id="painel">    
    <form id="frmObstetria" name="frmObstetria" method="POST" action="enfObstetria">
        <input type="hidden" name="hdfId" id="hdfId" value="<%=id%>">
        <h1>Dados do Atendimento</h1>
        <table>
            <tr>
                <td>Paciente <br/> <input type="text" id="txtNomePaciente" name="txtNomePaciente" value="<%=paciente%>" disabled /> </td>
                <td>Dt. Nascimento <br/> <input type="text" id="txtDataNascimento" name="txtDataNascimento" value="<%=data%>" disabled /> </td>
                <td>Responsável <br/> <input type="text" id="txtResponsavel" name="txtResponsavel" value="<%=responsavel%>" disabled /> </td>            
            </tr>
        </table>
        <h1>Dados da Obstetra</h1>
        <table>
            <tr>
                <%
                    ExameDAO daoExame = new ExameDAO();
                    List<Exame> exames = daoExame.selectAll();
                    DropDownList ddlExame = new DropDownList("ddlExame", "ddlExame", new ArrayList<Object>(exames), "getDescricao", "getId");                    
                %>
                <td>Exame: <br /><%=ddlExame.render()%></td>
            </tr>
            <tr>
                <td>Resultado: <br/> <textarea id="txtResultado" name="txtResultado" cols="50" rows="5"></textarea> </td>                
            </tr>
        </table>
        <br />
        <a class="botao" href="#" onclick="enviaForm('frmObstetria', '<%=servletUrl%>', 'erro');">Salvar</a>&nbsp;&nbsp;
        <a class="botao" href="<%=request.getContextPath() + "/relatorios/listagemEnfObstetria.jsp"%>">Voltar </a>
    </form>
</div>
<jsp:include page="../rodape.jsp"></jsp:include>
